﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Text;

/// <summary>
///UserCookiesManage 的摘要说明
/// </summary>
public class UserCookiesManage
{

    private static int cookiesTime = 720;

	public UserCookiesManage(){}

    public static void SaveAdminCookies(string name, string pwd) {
        Cookie.SaveCookie(ExamSys.admin_cookiesname.Trim(), HttpUtility.UrlEncode(name + "|" + pwd), cookiesTime);
    }

    public static void SaveManageCookies(Exam.Core.Model.Master master) {
        StringBuilder sb = new StringBuilder();
        sb.Append(master.MasterID.Trim());
        sb.Append("|");
        sb.Append(HttpUtility.UrlEncode(master.MasterName.Trim()));
        sb.Append("|");
        sb.Append(master.MasterPassword.Trim());
        sb.Append("|");
        sb.Append(master.DepartmentID.Trim());
        sb.Append("|");
        sb.Append(master.CourseId.Trim());
        Cookie.SaveCookie(ExamSys.teacher_cookiesname.Trim(), sb.ToString(), cookiesTime);
    }

    public static void SaveStudentCookies(Exam.Core.Model.Student model) {
        StringBuilder sb = new StringBuilder();
        sb.Append(model.StudentID.Trim());
        sb.Append("|");
        sb.Append(model.StudentNumber.Trim());
        sb.Append("|");
        sb.Append(HttpUtility.UrlEncode(model.StudentName.Trim()));
        sb.Append("|");
        sb.Append(model.StudentPassword.Trim());
        sb.Append("|");
        sb.Append(model.StudentEmail.Trim());
        sb.Append("|");
        sb.Append(model.DepartmentID.Trim());
        Cookie.SaveCookie(ExamSys.cookies_name.Trim(), sb.ToString(), cookiesTime);
    }

}